<!DOCTYPE html>
<html lang="ja" >
	<head>
	<meta charset="UTF-8" />
	<meta name="keywords" content="js here,encodeURI,decodeURI,JavaScript,URLエンコード,URLデコード" />
	<meta name="description" content="js here | URLエンコード、URLでコードを行うツールです" />
	<meta name="author" content="amigo*k.k">
	<link rel="stylesheet" href="css/style.css" media="screen" /> 
	<title>js here | url encode decode by javascript</title>
<script src="js/url_encoder.js"></script>
</head>
<body>
<div id="main_box">
	<header id="top_header">
		<a href="index.html"><img src="logo.jpg" /></a>
		<div id="top_ad">
		<script type="text/javascript"><!--
google_ad_client = "ca-pub-4498051423313001";
/* javascripthere url_encoder.html */
google_ad_slot = "5986644661";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
		</div>
 	</header>
 	<nav id="top_nav">
			<ul>
				<li><a class="topLinks" href="index.html">home</a></li>
				<li><a class="topLinks" href="about.html">About</a></li>
			</ul>
	</nav>
	<article>
    	<header>
			<hgroup>
				<h1>js here</h1>
				<h2>url encoder | url decoder by javascript</h2>
				<h2>javascriptでURLエンコード、URLデコードを行います。</h2>
    		</hgroup>
    	</header>
    	<!--content-->
		<div class="samplearea">
		<hr>
		<form id="sample070508a" name="f1" action="./">
		<p>URL encode：</p>
		<textarea id="to_encode" cols="100">日本語</textarea>
		<div class="buttons" >
		<input type="button" value="  url encode  " onclick="Encoder.encode_uri();" />
		</div>
		</form>
		<p id="encode_result">result</p>
		</div>
	
		<div class="samplearea">
		<form id="sample070508b" name="f2" action="./">
		<p>URL decode：</p>
		<textarea id="to_decode" cols="100">%E6%97%A5%E6%9C%AC%E8%AA%9E</textarea>
		<div class="buttons">
		<input type="button" value="url decode" onclick="Encoder.decode_uri();" />
		</div>
		</form>
		<p id="decode_result">result</p>
		</div>

    </article>

	<article>
	<header>
	<hgroup>
		<h2>It's important to remember protocol.</h2>
		<p>js here</p></hgroup>
	</header>
	<p>see: <a href="http://tools.ietf.org/html/rfc3986#section-2.1">rfc3986 section-2.1 Percent-Encoding</a></p>
	<p>see: <a href="http://tools.ietf.org/html/rfc1866#section-8.2.1">rfc1866#section-8.2.1 The form-urlencoded Media Type</a></p>
	</article>

	<article>
	<header>
	<hgroup>
	<h2>js here</h2>
	<script type="text/javascript">
	fileName="url_encoder.js";
	loadFile2(fileName);
	function loadFile2(fileName){
   		httpObj = new XMLHttpRequest();
   		httpObj.open('GET',fileName,true);
  		 httpObj.send(null);
   		httpObj.onreadystatechange = function(){
    		if( ( httpObj.readyState == 4) && (httpObj.status == 200)){
        		 document.getElementById("jshere").value=httpObj.responseText;
         		var data= JSON.parse(httpObj.responseText);
         		alert(JSON.stringify(data,null,'   '));
        		 document.getElementById("jshere").value="";
    		}
    	}
   	}
</script>
<textarea id="jshere" cols="100" rows="40">
/**
 * URL ENCODER
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this page.
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please contact twitter
 * to @agniuek so we can send you a copy immediately.
 *  
 * @category   javascript
 * @package    js here
 * @copyright  Copyright (c) 2012 agniuek
 * @license    New BSD License
 */

var Encoder = {};
Encoder.TO_ENCODE = 'to_encode';
Encoder.ENCODE_RESULT = 'encode_result';
Encoder.TO_DECODE = 'to_decode';
Encoder.DECODE_RESULT = 'decode_result';

Encoder.encode_uri = function() {
	var encode_result = encodeURI( document.getElementById(Encoder.TO_DECODE).value);
        if( (encode_result == null) || (encode_result == "") ){
          return;
        }
		document.getElementById(Encoder.ENCODE_RESULT).innerHTML = encode_result;
}

Encoder.decode_uri=function () {
	var decode_uri = decodeURI( document.getElementById(Encoder.TO_DECODE).value);
        if( (decode_uri == null) || ( decode_uri== "") ){
          return;
        }
	var decode_result = decode_uri.replace(/</g , "&lt;");
	document.getElementById(Encoder.DECODE_RESULT).innerHTML = decode_result;
}
-->
	</textarea>
	</hgroup>
	</header>
	<p>see: <a href="http://tools.ietf.org/html/rfc3986#section-2.1">rfc3986 section-2.1 Percent-Encoding</a></p>
	<p>see: <a href="http://tools.ietf.org/html/rfc1866#section-8.2.1">rfc1866#section-8.2.1 The form-urlencoded Media Type</a></p>
	</article>

	<footer id="the_footer">
	Copyright &copy; 2012 agniuek　All rights reserved.
	</footer>
</div>

</body>
</html>